/*
 * Created on 7/Abr/2004
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package org.cyborgas.xmltool.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.TreeViewer;

/**
 * @author rino
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class CollapseTreeAction extends Action {
	private TreeViewer treeViewer;
	private int level;
	
	/**
	 * @param treeViewer
	 * @param level
	 */
	public CollapseTreeAction(TreeViewer treeViewer, int level) {
		this.treeViewer = treeViewer;
		this.level = level;
		if (level == -1) {
			setText("Collapse &All");
		} else {
			setText("Collapse level &" + (level - 1));
		}
		setToolTipText(getText());
//		setImageDescriptor(Util.getImageDescriptor("fileopen.gif"));
	}
	
	public void run() {
		treeViewer.collapseToLevel(treeViewer.getInput(), level);
		treeViewer.expandToLevel(2);
	}

}
